package top.hkyzf.study.leetcode.array;

import org.junit.Test;

/**
 * @author zhufeng
 * @version 1.0
 * @date 2020-12-19 0:29
 */
public class 一维数组的动态和_1480 {

    @Test
    public void testRunningSum() {
        int [] value = new int[]{3,1,2,10,1};
        int[] result = this.runningSum(value);
        for(int v : result) {
            System.out.printf("%d ", v);
        }

    }

    public int[] runningSum(int[] nums) {
        int result [] = new int[nums.length];
        int sum = 0;
        for (int i=0; i<nums.length; i++) {
            sum = sum + nums[i];
            result[i] = sum;
        }
        return result;
    }
}
